Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

error using transfer function when a={1} and b={1}

error using transfer function when a={1} and b={1}

Hello,

When using "Modelica.Blocks.Continuous.TransferFunction" with a={1} and b={1}, the following error and warning shows up:

[CodegenC.tpl:8994:11-8994:11] Error: Template error: vector() call does not have a C implementation vector({{transferfunction1.b[1]}})
[C:/OpenModelica/lib/omlibrary/Modelica 3.2.1/Blocks/Continuous.mo:1244:5-1244:61] Warning: Failed to deduce dimensions of bb due to unknown dimensions of modifier vector({{transferfunction1.b[1]}}).

Looking at TransferFunction code, the problem comes from the vector function in the following line:

bb[:] = vector([zeros(max(0, na - nb), 1); b]);

which for my case it simply become:

bb[:] = vector({{transferfunction1.b[1]}});

why vector function can not convert {{transferfunction1.b[1]}} to a vector?

Thanks,
Arvin

Re: error using transfer function when a={1} and b={1}

Do you have a small model for this so I don't need to figure out how to use the block? It should be an easy fix.

Re: error using transfer function when a={1} and b={1}

Here it is:

Code:


model tmp
  //    Modelica.Blocks.Sources.Step step1(startTime = 2) annotation(Placement(visible = true, transformation(origin = {-20, 20}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  //  parameter Real[:] b = {1, 2};
  //  Real[3] c = {2, 3, 4};
  //  Real[:,1] d = [b; c];
  //  parameter Real b1[:, 1] = [zeros(max(0, 0), 1); b];
  //  parameter Real bb[:] = vector(b1);
  //  parameter Real a[:,1] = {{1}};
  //  parameter Real aa[:] = vector(a);
  // vector([zeros(0,1);1]);
  Modelica.Blocks.Continuous.TransferFunction transferfunction1 annotation(Placement(visible = true, transformation(origin = {0, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Sources.Step step1(startTime = 1) annotation(Placement(visible = true, transformation(origin = {-40, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(step1.y, transferfunction1.u) annotation(Line(points = {{-29, 0}, {-12.8668, 0}, {-12.8668, 0.677201}, {-12.8668, 0.677201}}, color = {0, 0, 127}));
  annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), Diagram(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2, 2})), experiment(StartTime = 0, StopTime = 5, Tolerance = 1e-06, Interval = 0.01));
end tmp;

forget the comments. i just wrote them to go step by step through the TransferFunction code and find out how the error is produced.

Thanks,
Arvin

Edited by: arvinmor - Oct-09-14 19:00:47

Re: error using transfer function when a={1} and b={1}

Fixed in r22707

There are 0 guests and 0 other users also viewing this topic
You are here: